package Servlet.Manager;

import Service.UpdateManagerService;
import Service.UpdateUserService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/managerUpdateServlet")
public class ManagerUpdateServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("application/json;charset=utf-8");
        String username = req.getParameter("username");//用户名
        String password1 = req.getParameter("password1");//原密码
        String password2 = req.getParameter("password2");//新密码
        String s = username.trim();
        Boolean flag = UpdateManagerService.Update(s, password1, password2);
        PrintWriter out = resp.getWriter();
        out.print(flag);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
